using System;
using System.Data;
using System.Text;
using System.ComponentModel;
using System.Collections.Generic;

namespace teavch.Utilities.Electrical.Design.Gui.LineDiagram
{
	public partial class CircuitBreaker : ElectricalSymbol
	{
		
		private float _hrRation = .8f;

		public CircuitBreaker()
		{
			InitializeComponent();
		}

		protected override void OnPaint( System.Windows.Forms.PaintEventArgs e )
		{
			base.OnPaint( e );
			this.Paint( e );
		}

		protected override void OnResize( EventArgs e )
		{
			base.OnResize( e );
			ResizeNow( e );
		}

		private void ResizeNow( EventArgs ea )
		{
			this.Refresh();
		}

		private new void Paint( System.Windows.Forms.PaintEventArgs pea )
		{
			int _x1 = 0, _x2 = 0;
			int _y1 = 0, _y2 = 0;

			_x1 = 0;
			_y1 = 0;
			_x2 = this.SymbolSize;
			_y2 = ( int )( this.SymbolSize * this._hrRation );

			this.Width = _x2 + this.BorderWidth;
			this.Height = _y2 + this.BorderWidth;

			System.Drawing.Drawing2D.PathGradientBrush _gBrush = null;
			System.Drawing.Drawing2D.GraphicsPath _gpath = new System.Drawing.Drawing2D.GraphicsPath();

			_gpath.AddRectangle( new System.Drawing.Rectangle( new System.Drawing.Point( _x1, _y1 ), new System.Drawing.Size( _x2, _y2 ) ) );

			if ( this.Fill == true )
			{
				_gBrush = new System.Drawing.Drawing2D.PathGradientBrush( _gpath );
				_gBrush.CenterColor = this.Parent.BackColor;
				_gBrush.SurroundColors = new System.Drawing.Color[] { this.State == SymbolState.On ? System.Drawing.Color.Red : System.Drawing.Color.Lime };
				pea.Graphics.FillPath( _gBrush, _gpath );
			}

			_gpath.AddLine( _x2, _y1, _x1, _y2 );
			_gpath.AddLine( _x1, _y1, _x2, _y2 );

			pea.Graphics.DrawPath( this.Pen, _gpath );
		}

	}
}